package com.base.myproject.client.tools;

import com.google.gwt.http.client.Request;
import com.google.gwt.http.client.RequestCallback;
import com.google.gwt.http.client.RequestException;
import com.google.gwt.http.client.Response;
import com.google.gwt.user.client.Timer;

public class DataWin implements RequestCallback{
	String datawinid = null;
	String datawin = null;
	int b = 0;
	public DataWin(String datawinid)
	{
		this.datawinid = datawinid;
		
	}

	public String getDataWinFromServer() throws RequestException
	{
		String  str = "";
		SendServlet ss = new SendServlet();
//		ss.sendServlet("BaseServlet", "Action=getdatawin?datawinid="+datawinid, new AsyncCallback(){
//			AsyncCallback dd=null;
//		});
//		
		return str;
	}
	@Override
	public void onError(Request request, Throwable exception) {
		// TODO Auto-generated method stub
		b=-1;
	}

	@Override
	public void onResponseReceived(Request request, Response response) {
		datawin = response.getText();
		b=1;
	}
	public String getDateWin()
	{
		Timer timer =new Timer() {public void run() {
			if(b!=0)
			{
				this.cancel();
			}
			System.out.println("t2"); 
	        }
		};
	
		while(b==0)
		{
			timer.schedule(1000);
			 timer.scheduleRepeating(1000); 
			timer.run();
			System.out.println("t1");
		}
		if(b!=0)
		{
			
			
		
			if(b==-1)
				return null;
			else
				return datawin;
			
		}
		return null;
	}
}
